package thread_1;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author Klys
 * @Date 2023/3/5 12:44
 * @Description
 * @Version 1.0
 */
public class CallableThread implements Callable<String> {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> stringFutureTask = new FutureTask<>(new CallableThread());
        Thread thread = new Thread(stringFutureTask);
        thread.start();
        String res = stringFutureTask.get();
        System.out.println(res);
    }

    @Override
    public String call() throws Exception {
        return "我是stringFutureTask";
    }
}
